<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space20">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">模型文件管理模块</div>
                        <div class="layui-card-body">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <fieldset class="layui-elem-field site-demo-button">
                                        <legend>API 接口训练</legend>
                                        <div class="layui-field-box">
                                            <div class="layui-tab layui-tab-brief" lay-filter="">
                                                <ul class="layui-tab-title">
                                                    <li class="layui-this">模型训练</li>
                                                    <li>贝叶斯分类</li>
                                                    <li>文件训练</li>
                                                </ul>
                                                <div class="layui-tab-content">
                                                    <div class="layui-tab-item layui-show">
                                                        <div class="bayes">
                                                            <form class="layui-form layui-form-pane form_bayes"
                                                                  action="">
                                                                <div class="layui-form-item div_bayes_text">

                                                                    <label class="layui-form-label">类别名</label>
                                                                    <div class="layui-input-inline"
                                                                         style="width: 100px;">
                                                                        <input type="text" name="typeName"
                                                                               lay-verify="required" placeholder="必需"
                                                                               autocomplete="off" class="layui-input">
                                                                    </div>

                                                                    <label class="layui-form-label">训练语料</label>
                                                                    <div class="layui-input-inline" style="width: 49%">
                                                                        <input type="text" name="SIMILAR_TEXT"
                                                                               lay-verify="title"
                                                                               autocomplete="off"
                                                                               placeholder="以【 ||| 】分割每份语料"
                                                                               class="layui-input"/>
                                                                    </div>
                                                                    <div class="layui-input-inline"
                                                                         style="width: 120px">
                                                                        <div class="layui-btn-group">
                                                                            <button type='button' id="btn_add_onlyone"
                                                                                    class="layui-btn layui-btn"
                                                                                    onclick='addBayesInput("form_bayes")'>
                                                                                <i class="layui-icon">&#xe654;</i>
                                                                            </button>
                                                                            <button type='button'
                                                                                    id="btn_delete_onlyone"
                                                                                    class="layui-btn layui-btn-warm layui-btn"
                                                                                    onclick='deleteBayesInput("form_bayes",$(this))'>
                                                                                <i class="layui-icon">&#xe640;</i>
                                                                            </button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </form>
                                                        </div>
                                                        <button class="layui-btn layui-btn-fluid" style="width: 96.5%;"
                                                                onclick="handonBayesData()">
                                                            提交语料
                                                        </button>
                                                        <fieldset class="layui-elem-field layui-field-title">
                                                            <legend>训练结果</legend>
                                                            <div id="bayes_res_md5" class="layui-field-box">

                                                            </div>
                                                        </fieldset>

                                                        <fieldset class="layui-elem-field layui-field-title">
                                                            <legend>结果说明</legend>
                                                            <div class="layui-field-box">
                                                                <blockquote class="layui-elem-quote layui-quote-nm"><p
                                                                        class="gray-p">
                                                                    训练结果为一串MD5的字符串，作为模型的Tag，模型已在本地持久化，在预测分类时，只需要输入模型Tag，后台会自动对该模型反序列化并加载。</p>
                                                                </blockquote>

                                                            </div>
                                                        </fieldset>


                                                    </div>
                                                    <div class="layui-tab-item">
                                                        <blockquote class="layui-elem-quote layui-text">
                                                            您可以输入模型Tag值，并尝试使用Bayes的API接口。本模块支持多文本展示，结果由弹窗弹出。
                                                        </blockquote>
                                                        <fieldset class="layui-elem-field layui-field-title">
                                                            <legend>参数输出</legend>
                                                            <div class="layui-field-box">
                                                                <form class="layui-form layui-form-pane" action="">
                                                                    <div class="layui-form-item">
                                                                        <label class="layui-form-label">模型Tag</label>
                                                                        <div class="layui-input-block">
                                                                            <input type="text" id="model_tag"
                                                                                   name="model_tag" autocomplete="off"
                                                                                   placeholder="请输入模型Tag值"
                                                                                   class="layui-input">
                                                                        </div>
                                                                    </div>
                                                                    <div id="div_bayes_inner_classify"
                                                                         class="bayes_inner_classify">
                                                                        <div class="layui-form-item div_ready_classify_text">
                                                                            <label class="layui-form-label">待分类文本</label>
                                                                            <div class="layui-input-inline"
                                                                                 style="width: 72%">
                                                                                <input type="text" name="TEXT"
                                                                                       lay-verify="title"
                                                                                       autocomplete="off"
                                                                                       placeholder="输入文本"
                                                                                       class="layui-input"/>
                                                                            </div>
                                                                            <div class="layui-input-inline"
                                                                                 style="width: 120px">
                                                                                <div class="layui-btn-group">
                                                                                    <button type='button' id=""
                                                                                            class="layui-btn layui-btn"
                                                                                            onclick='addReadyToClassifyInput("bayes_inner_classify")'>
                                                                                        <i class="layui-icon">&#xe654;</i>
                                                                                    </button>
                                                                                    <button type='button' id=""
                                                                                            class="layui-btn layui-btn-warm layui-btn"
                                                                                            onclick='deleteReadyToClassifyInput("bayes_inner_classify",$(this))'>
                                                                                        <i class="layui-icon">&#xe640;</i>
                                                                                    </button>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </form>
                                                            </div>
                                                            <button class="layui-btn layui-btn-fluid" type="button"
                                                                    onclick="handonClassify()">执行分析
                                                            </button>
                                                        </fieldset>

                                                        <fieldset class="layui-elem-field layui-field-title">
                                                            <legend>结果输出</legend>
                                                            <div class="layui-field-box">
                                                                <blockquote class="layui-elem-quote layui-quote-nm"><p
                                                                        class="gray-p">
                                                                </p>
                                                                    由于内容展示面积较小，又需要展示多文本分类的结果，故结果输出完毕会以个性化弹窗的方式进行可视化渲染。</p>
                                                                </blockquote>

                                                            </div>
                                                        </fieldset>
                                                    </div>
                                                    <div class="layui-tab-item">
                                                        <blockquote class="layui-elem-quote layui-quote-nm"><p
                                                                class="gray-p">

                                                            为了确保服务器能够正常解析文件并完成训练，文件训练的格式说明：
                                                            -分类A.txt
                                                            -分类B.txt
                                                            -分类C.txt
                                                            -分类D.txt

                                                        </blockquote>
                                                        <fieldset class="layui-elem-field layui-field-title"
                                                                  style="margin-top: 30px;">
                                                            <legend>多文件列表</legend>
                                                        </fieldset>

                                                        <div class="layui-upload">
                                                            <button type="button" class="layui-btn layui-btn-normal"
                                                                    id="testList">选择多文件类别语料
                                                            </button>
                                                            <div class="layui-upload-list">
                                                                <table class="layui-table">
                                                                    <thead>
                                                                    <tr>
                                                                        <th>文件名</th>
                                                                        <th>大小</th>
                                                                        <th>状态</th>
                                                                        <th>操作</th>
                                                                    </tr>
                                                                    </thead>
                                                                    <tbody id="demoList"></tbody>
                                                                </table>
                                                            </div>
                                                            <button type="button" class="layui-btn" id="testListAction">
                                                                上传分类语料并训练
                                                            </button>
                                                        </div>
                                                        <fieldset class="layui-elem-field layui-field-title"
                                                                  style="margin-top: 30px;">
                                                            <legend>训练模型Tag</legend>
                                                        </fieldset>
                                                        <blockquote id="modelTags"
                                                                    class="layui-elem-quote layui-quote-nm"><p
                                                                class="gray-p">


                                                        </blockquote>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </fieldset>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">已训练的模型管理</div>
                        <div class="layui-card-body">
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <fieldset class="layui-elem-field site-demo-button">
                                        <legend>模型预览</legend>
                                        <div class="layui-field-box">
                                            <table class="layui-hide" id="bayes_models"
                                                   lay-filter="bayes_models"></table>

                                        </div>
                                    </fieldset>

                                </div>
                                <div class="layui-col-md12">

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>


    /**
     * 基于贝叶斯分类器的情感识别
     */

    var emotion_model_tag;

    function emotion() {

        var tag = emotion_model_tag;

        var text = $('#text_main_text').val();
        var obj = new Object();
        var texts = new Array();
        var tObj = new Object();
        tObj.text = text;
        texts.push(tObj);
        obj.tag = tag;
        obj.texts = texts;
        var requestJson = JSON.stringify(obj);
        //发送异步请求
        jQuery.ajax({
            url: discourse_emotion_path,
            type: "post",
            data: requestJson,
            dataType: "json",
            contentType: "application/json;charset=utf-8"
        }).done(function (data) {
            console.log(data);
            loadEmotionGraph(data);
            layer.close(layerIndex);
        }).fail(function (data) {
            layer.alert("请求失败", {icon: 7});
            layer.close(layerIndex);
        });

    }


    /**
     * 增加贝叶斯分类的语料
     * @param formClassName
     */
    function addBayesInput(formClassName) {

        var selecter = "." + formClassName;
        if ($(selecter).find('.div_bayes_text').length == 100) {
            layer.msg("4个够演示就好啦，别点了");
            return;
        }

        var textGroup = $('.' + formClassName).find('.div_bayes_text').parent();

        textGroup.append('   <div class="layui-form-item div_bayes_text">' +
            '                        <label class="layui-form-label">类别名</label>' +
            '                        <div class="layui-input-inline" style="width: 100px;">' +
            '                            <input type="text" name="typeName" lay-verify="required" placeholder="必需"' +
            '                                   autocomplete="off" class="layui-input">' +
            '                        </div>' +
            '                        <label class="layui-form-label">训练语料</label>' +
            '                        <div class="layui-input-inline" style="width: 49%">' +
            '                            <input type="text" name="SIMILAR_TEXT" lay-verify="title"' +
            '                                   autocomplete="off"' +
            '                                   placeholder="以【 ||| 】分割每份语料"' +
            '                                   class="layui-input"/>' +
            '                        </div>' +
            '                        <div class="layui-input-inline" style="width: 120px">' +
            '                            <div class="layui-btn-group">' +
            '                                <button type=\'button\' id="btn_add_onlyone"' +
            '                                        class="layui-btn layui-btn"' +
            '                                        onclick=\'addBayesInput("form_bayes")\'>' +
            '                                    <i class="layui-icon">&#xe654;</i>' +
            '                                </button>' +
            '                                <button type=\'button\' id="btn_delete_onlyone"' +
            '                                        class="layui-btn layui-btn-warm layui-btn"' +
            '                                        onclick=\'deleteBayesInput("form_bayes",$(this))\'>' +
            '                                    <i class="layui-icon">&#xe640;</i>' +
            '                                </button>' +
            '                            </div>' +
            '                        </div>' +
            '                    </div>');

        layui.form.render();
        layui.element.init();

    }


    /**
     * 删除贝叶斯分类的语料
     * @param formClassName
     * @param node
     */
    function deleteBayesInput(formClassName, node) {


        if ($('.' + formClassName).find('.div_bayes_text').length == 1) {
            layer.msg("你删了这最后1个我怎么演示啊？😁");
            return;
        }
        node.parent().parent().parent().remove();
        layui.form.render();
        layui.element.init();
    }


    /**
     * 提交贝叶斯训练的语料，返回模型的标签
     */
    function handonBayesData() {

        //构建json字符串
        var obj = new Object();
        var objData = new Array();
        var nodes = $('.form_bayes').children();
        for (var i = 0; i < nodes.length; i++) {
            var tmpObj = new Object();
            var tmpArr = new Array();
            var typeName = $(nodes[i]).find('input[name=\'typeName\']').val();
            var sample = $(nodes[i]).find('input[name=\'SIMILAR_TEXT\']').val().split("|||");
            for (var j = 0; j < sample.length; j++) {
                var o = new Object();
                o.text = sample[j];
                tmpArr.push(o);
            }
            tmpObj.name = typeName;
            tmpObj.sample = tmpArr;
            objData.push(tmpObj);
        }
        obj.data = objData;
        console.log(obj);
        var requestJson = JSON.stringify(obj);
        //发送异步请求
        jQuery.ajax({
            url: discourse_bayes_train,
            type: "post",
            data: requestJson,
            dataType: "json",
            contentType: "application/json;charset=utf-8"
        }).done(function (data) {
            console.log(data);
            $('#bayes_res_md5').empty();
            $('#bayes_res_md5').append('训练模型Tag：<i style="color: #A67727;">' + data.data.tag + '</i>');
            layer.close(layerIndex);
        }).fail(function (data) {
            layer.alert("请求失败", {icon: 7});
            layer.close(layerIndex);
        });


    }


    /**
     * 贝叶斯增加预测分类的
     */
    function addReadyToClassifyInput(formClassName) {


        var selecter = "." + formClassName;
        if ($(selecter).find('.div_ready_classify_text').length == 100) {
            layer.msg("5个够演示就好啦，别点了");
            return;
        }

        var textGroup = $('.' + formClassName).find('.div_ready_classify_text').parent();

        textGroup.append('  <div class="layui-form-item div_ready_classify_text">' +
            '                                <label class="layui-form-label">待分类文本</label>' +
            '                                <div class="layui-input-inline" style="width: 72%">' +
            '                                    <input type="text" name="TEXT" lay-verify="title"' +
            '                                           autocomplete="off"' +
            '                                           placeholder="输入文本"' +
            '                                           class="layui-input"/>' +
            '                                </div>' +
            '                                <div class="layui-input-inline" style="width: 120px">' +
            '                                    <div class="layui-btn-group">' +
            '                                        <button type=\'button\' id=""' +
            '                                                class="layui-btn layui-btn"' +
            '                                                onclick=\'addReadyToClassifyInput("bayes_inner_classify")\'>' +
            '                                            <i class="layui-icon">&#xe654;</i>' +
            '                                        </button>' +
            '                                        <button type=\'button\' id=""' +
            '                                                class="layui-btn layui-btn-warm layui-btn"' +
            '                                                onclick=\'deleteReadyToClassifyInput("bayes_inner_classify",$(this))\'>' +
            '                                            <i class="layui-icon">&#xe640;</i>' +
            '                                        </button>' +
            '                                    </div>' +
            '                                </div>' +
            '                            </div>');

        layui.form.render();
        layui.element.init();

    }


    /**
     * 删除贝叶斯等待分类的语料
     * @param formClassName
     * @param node
     */
    function deleteReadyToClassifyInput(formClassName, node) {


        if ($('.' + formClassName).find('.div_ready_classify_text').length == 1) {
            layer.msg("你删了这最后1个我怎么演示啊？😁");
            return;
        }
        node.parent().parent().parent().remove();
        layui.form.render();
        layui.element.init();
    }


    /**
     * 执行贝叶斯分类
     */
    function handonClassify() {

        var obj = new Object();
        var texts = new Array();
        var tag = $('#model_tag').val();
        var nodes = $('#div_bayes_inner_classify').children();
        for (var i = 0; i < nodes.length; i++) {
            var text = $(nodes[i]).find('input[name=\'TEXT\']').val();
            var tObj = new Object();
            tObj.text = text;
            texts.push(tObj);
        }

        obj.tag = tag;
        obj.texts = texts;
        var requestJson = JSON.stringify(obj);
        //发送异步请求
        jQuery.ajax({
            url: discourse_emotion_path,
            type: "post",
            data: requestJson,
            dataType: "json",
            contentType: "application/json;charset=utf-8"
        }).done(function (data) {
            console.log(data);
            printRes(data);
            layer.close(layerIndex);
        }).fail(function (data) {
            layer.alert("请求失败", {icon: 7});
            layer.close(layerIndex);
        });


        /**
         * 输出结果
         * @param data
         */
        function printRes(data) {

            var res = data.data.res;
            var legend = data.data.catlog;
            var resStr = "";


            for (var i = 0; i < res.length; i++) {

                resStr += '<fieldset class="layui-elem-field">' +
                    '        <legend>结果集合</legend>' +
                    '        <div class="layui-field-box">' +
                    '                <fieldset class="layui-elem-field layui-field-title">' +
                    '                        <legend>原文</legend>' +
                    '                        <div class="layui-field-box">' +
                    '                                <blockquote class="layui-elem-quote  layui-quote-nm">' + res[i].text + '</blockquote></div>' +
                    '                </fieldset>' +
                    '                <fieldset class="layui-elem-field layui-field-title">' +
                    '                        <legend>分类结果</legend>' +
                    '                        <div class="layui-field-box"></div>' +
                    '                </fieldset>' +
                    '                <div class="layui-row">' +
                    '                        <div class="layui-col-md12">' +
                    '                                <div class="layui-btn-container">' +
                    '                                        <div id="div_tmp_graph_' + i + '" style="width: 900px;height:500px;"></div>' +
                    '                                </div>' +
                    '                        </div>' +
                    '                </div>' +
                    '        </div>' +
                    '</fieldset>';

            }


            //弹出窗口
            layer.open({
                type: 1,
                title: '结果展示',
                shade: 0,
                maxmin: true,
                skin: 'layui-layer-rim', //加上边框
                area: ['840px', '480px'], //宽高
                content: resStr
            });

            for (var i = 0; i < res.length; i++) {

                var thisChart = null;
                // 基于准备好的dom，初始化ECharts实例
                if (thisChart != null && thisChart != "" && thisChart != undefined) {
                    thisChart.dispose();
                }
                thisChart = echarts.init(document.getElementById('div_tmp_graph_' + i), 'macarons');
                thisChart.showLoading();


                var option_raw = {
                    title: {
                        text: '贝叶斯分类结果概率图',
                        subtext: '贝叶斯模型',
                        x: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        x: 'center',
                        y: 'bottom',
                        data: ['rose1', 'rose2', 'rose3', 'rose4', 'rose5', 'rose6', 'rose7', 'rose8']
                    },
                    toolbox: {
                        show: true,
                        feature: {
                            mark: {show: true},
                            dataView: {show: true, readOnly: false},
                            magicType: {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore: {show: true},
                            saveAsImage: {show: true}
                        }
                    },
                    calculable: true,
                    series: [
                        {
                            name: '概率大小',
                            type: 'pie',
                            radius: [30, 120],
                            center: ['50%', '50%'],
                            roseType: 'radius',
                            data: res[i].classify
                        }
                    ]
                };

                thisChart.hideLoading();
                thisChart.setOption(option_raw, true);

            }


        }
    }


</script>

<!--上传部分代码-->
<script>
    //存储返回数据的Arr
    var arr = new Array();

    layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload;
        //多文件列表示例
        var demoListView = $('#demoList')
            , uploadListIns = upload.render({
            elem: '#testList'
            , url: '/file/upload/bayes.do'
            , accept: 'file'
            , multiple: true
            , auto: false
            , bindAction: '#testListAction'
            , choose: function (obj) {
                var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function (index, file, result) {
                    var tr = $(['<tr id="upload-' + index + '">'
                        , '<td>' + file.name + '</td>'
                        , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
                        , '<td>等待上传</td>'
                        , '<td>'
                        , '<button class="layui-btn layui-btn-mini demo-reload layui-hide">重传</button>'
                        , '<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</button>'
                        , '</td>'
                        , '</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function () {
                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function () {
                        delete files[index]; //删除对应的文件
                        tr.remove();
                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                    });

                    demoListView.append(tr);
                });
            }
            , done: function (res, index, upload) {
                if (res.status == 0) { //上传成功
                    var tr = demoListView.find('tr#upload-' + index)
                        , tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                    tds.eq(3).html(''); //清空操作
                    // 执行第二段Ajax
                    var obj = new Object();
                    obj.name = res.data[0].fileName;
                    var a = new Array();
                    var innerObj = new Object();
                    innerObj.text = res.data[0].content;
                    a.push(innerObj);
                    obj.sample = a;
                    arr.push(obj);
                    trainning();
                    // $('#modelTags').empty();
                    // $('#modelTags').append(res.tag);
                    layer.alert("上传成功！");
                    return delete this.files[index]; //删除文件队列已经上传成功的文件

                }
                this.error(index, upload);
            }
            , error: function (index, upload) {
                var tr = demoListView.find('tr#upload-' + index)
                    , tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });

    });

    /**
     * 调用接口训练
     */
    function trainning() {

        if ($('.layui-upload').find('tr').length - 1 == arr.length) {
            console.log(arr);
            var obj = new Object();
            obj.data = arr;
            var requestJson = JSON.stringify(obj);
            //发送异步请求
            jQuery.ajax({
                url: discourse_bayes_train,
                type: "post",
                data: requestJson,
                dataType: "json",
                contentType: "application/json;charset=utf-8"
            }).done(function (data) {
                console.log(data);
                $('#modelTags').empty();
                $('#modelTags').append('训练模型Tag：<i style="color: #A67727;">' + data.data.tag + '</i>');
                arr = new Array();
                layer.close(layerIndex);
            }).fail(function (data) {
                layer.alert("请求失败", {icon: 7});
                layer.close(layerIndex);
            });
        }

    }


    //模型数据
    var mydata;

    //发送异步请求

    jQuery.ajax({
        url: "/admin/models/bayes.do",
        type: "get",
        dataType: "json",
        contentType: "application/json;charset=utf-8"
    }).done(function (data) {
        mydata = data.data;
    }).fail(function (data) {
        layer.alert("请求失败", {icon: 7});
        layer.close(layerIndex);
    });


    /**
     * 表格的
     */
    layui.use('table', function () {
        var table = layui.table;

        table.render({
            elem: '#bayes_models'
            , data: mydata
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , cols: [[
                {field: 'name', align: 'center', title: '模型类别'}
                , {field: 'dir', title: '目录'}
                , {field: 'description', title: '模型信息'}
                , {fixed: 'right', width: 178, align: 'center', toolbar: '#barDemo', title: "操作栏"}
            ]]
        });


        //监听工具条
        table.on('tool(bayes_models)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                //弹出窗口
                layer.open({
                    type: 1,
                    title: '每个主题的描述',
                    shade: 0,
                    maxmin: true,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['840px', '480px'], //宽高
                    content: '<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">' +
                    '  <legend>主题描述</legend>' +
                    '</fieldset>' +
                    ' ' +
                    '      <pre class="layui-code">' +
                    data.topics +
                    '      </pre>'
                });

            } else if (obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    obj.del();
                    layer.close(index);
                    deleteBayesModels(obj.data.id);
                });
            } else if (obj.event === 'edit') {
                layer.alert('编辑行：<br>' + JSON.stringify(data))
            }
        });
    });


    // 删除贝叶斯模型数据
    function deleteBayesModels(id) {
        var layerIndex = layer.load(2);
        //发送异步请求
        jQuery.ajax({
            url: "/admin/models/bayes.do?id=" + id,
            type: "delete",
            dataType: "json",
            contentType: "application/json;charset=utf-8"
        }).done(function (data) {
            console.log(data);
            layui.layer.alert("删除成功");
        }).fail(function (data) {
            layer.alert("请求失败", {icon: 7});
            layer.closeAll();
        });
    }

</script>

<script src="/static/layui/js/common/publicVars.js"></script>